package com.six.work.servicesImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.six.work.entity.*;
import com.six.work.mapper.InvitationMapper;
import com.six.work.services.InvitationServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InvitationServicesImpl implements InvitationServices {
    @Autowired
    private InvitationMapper invitationMapper;
//    private Object PageInfo;

    @Override  //多表关联
    public PageInfo<InvView> findAllInvitation(Integer num) {
        PageHelper.startPage(num, 5);
        List<InvView> lists = invitationMapper.findAllInvitation();
        PageInfo<InvView> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }


    //按帖子标题查询
    @Override
    public List<Invitation> findPostByTitle(String title) {
        List<Invitation> lists = invitationMapper.findPostByTitle(title);
        return lists;
    }

    //删除帖子
    @Override
    public Integer DelPostByID(Integer post_id){
        return invitationMapper.DelPostByID(post_id);
    }

    //查看帖子内容
    @Override
    public List<Invitation> findContent(Integer post_id){
        return invitationMapper.findContent(post_id);
    }

    @Override  //新增
    public Integer insertInvitation(Invitation invitation) {
        return invitationMapper.insertInvitation(invitation);
    }


//    @Override   //修改
//    public Invitation SelectInvByID(Integer post_id) {
//        return invitationMapper.SelectInvByID(post_id);
//    }

    @Override
    public Invitation SelectInvByID(Integer post_id) {
        return invitationMapper.SelectInvByID(post_id);
    }



    @Override     //修改
    public Integer updateInvitation(Invitation invitation) {
        return invitationMapper.updateInvitation(invitation);
    }


}
